﻿using System;
using System.Reflection;

namespace TeF.Runner
{
    internal class Test : TestStateEntityBase, ITest, ITestEntityChildOfT<TestContainer, Test>
    {
        public Test(MethodInfo methodInfo, bool ignored, TestContainer testContainer, TestSetUp setUp, TestTearDown tearDown)
            : base(ignored)
        {
            if (methodInfo == null)
                throw new ArgumentNullException("methodInfo");
            if (testContainer == null)
                throw new ArgumentNullException("testContainer");

            MethodInfo = methodInfo;

            Parent = testContainer;

            SetUp = setUp;
            TearDown = tearDown;
        }

        public MethodInfo MethodInfo { get; private set; }

        public override string Name
        {
            get { return MethodInfo.Name; }
        }

        public TestContainer Parent { get; private set; }

        public ITestContainer Container
        {
            get { return Parent; }
        }

        public TestSetUp SetUp { get; private set; }
        public TestTearDown TearDown { get; private set; }

        public void Run()
        {
            if (Ignored)
            {
                SetState(TestState.Skipped);
                return;
            }

            throw new NotImplementedException();
        }
    }
}
